<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1" action="${systemctx}/sample/saveSample.web" method="post">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.bascsetting.title")%>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.preferential") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.preferential.title") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request, "systemmanage.preferential.column.code")%>
						</label>
						<span><input type="text" id="code" name="code"/></span> 
					</li>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.preferentialType")%>
						</label>
						<span><select id="preferentialType" name="preferentialType" class="validate[required]"></select></span> 
					</li>
				</ul>
				<ul>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.medium")%>
						</label>
						<span>
							<select id="medium" name="medium" class="validate[required]">
								<option value="">
									<%=MessageResourcesUtils.getMessage(request, "systemmanage.preferential.select.all") %>
								</option>
								<c:forEach items="${mediumList}" var="medium">
									<option value="${medium.value}">${medium.dataContent}</option>
								</c:forEach>
							</select>
						</span> 
					</li>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.channel")%>
						</label>
						<span>
							<select id="channel" name="channel" class="validate[required]">
								<option value="">
									<%=MessageResourcesUtils.getMessage(request, "systemmanage.preferential.select.all") %>
								</option>
								<c:forEach items="${channelList}" var="channel">
									<option value="${channel.value}">${channel.dataContent}</option>
								</c:forEach>
							</select>
						</span>  
					</li>
				</ul>
			</div>	
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery" name="butQuery" value="<%=MessageResourcesUtils.getMessage(request, "common.button.query") %>" />
			<input type="button" class="btn btn-default" onclick="toAddPreferentialCode()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.add")%>" />
		</div>
		<table>
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
	$(document).ready(function(){	
		$("#preferentialType").selectutil({
			optModel :<%=SysConstant.PreferentialType.getModelJSONString(true,false )%>,
			optDefault :''
		});
		
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.title")%>',
			width : 'auto',
			nowrap : true,
			autoRowHeight : false,
			singleSelect : true,
			striped : true,
			url : '${systemctx}/systemmanage/preferential/queryPreferentialCodeListInfoDataGrid.json',
			sortName: 'create_time',
			sortOrder: 'desc',
			remoteSort : true,
			idField : 'id',
			pagination : true,
			rownumbers : true,
			showFooter : true,
			queryParams:$('#form1').serializeObject(),
			columns : [[ 
				{
					field : 'id',
					title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation") %>',
					width : 60,
					align : 'center',
					formatter : operate
				},
			  	{title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.code")%>',field : 'code',sortable : true,align : 'left',width:100},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.preferentialType")%>',field : 'preferentialtype',sortable : true,align : 'left',width:120},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.maxLimit")%>',field : 'maxlimit',sortable : true,align : 'left',width:100},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.preferentialRatio")%>',field : 'preferentialratio',sortable : true,align : 'left',width:85},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.medium")%>',field : 'medium',sortable : true,width : 60,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.channel")%>',field : 'channel',sortable : true,width : 70,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.dataStatus")%>',field : 'datastatus',sortable : true,width : 60,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.createTime")%>',field : 'createtime',sortable : true,width : 150,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.creater")%>',field : 'creater',sortable : true,width : 90,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.usedTime")%>',field : 'usedtime',sortable : true,width : 150,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.userId")%>',field : 'userid',sortable : true,width : 90,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.usedResult")%>',field : 'usedresult',sortable : true,width : 90,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.deadlineTime")%>',field : 'deadlinetime',sortable : true,width : 150,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.actualDeadlineTime")%>',field : 'actualdeadlinetime',sortable : true,width : 150,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.preferential.column.deadlineEditer")%>',field : 'deadlineediter',sortable : true,width : 90,align : 'left'}
	        ]],
			onLoadSuccess : function(data) {

			}
		});		
		$('#butQuery').click(function() {
			$('#datagrid').datagrid('load',$('#form1').serializeObject());
		});	
		
		function operate(val, row) {
			var datastatus = row.datastatus;
			var dead = "<%=MessageResourcesUtils.getMessage(request, "systemmanage.preferential.button.dead") %>";
			if(datastatus == 'UseUp'){
				return "<a disabled=\"disabled\" class=\"easyui-linkbutton disabled\" style=\"color:grey\">"+dead+"</a>";
			}else{
				return "<a href=\"javascript:void(0);\" class=\"easyui-linkbutton\" onclick=\"preferentialCodeDead('"+val+"')\">"+dead+"</a>";
			}
			
		}

	});
	function toAddPreferentialCode(){
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/systemmanage/preferential/toAddPreferentialCode.web"
		});
	}

	
	function preferentialCodeDead(val) {
		var id = val;
		if (confirm("<%=MessageResourcesUtils.getMessage(request, "systemmanage.preferential.alert2") %>")) {
			//正在执行...
			showSending();
			$.ajax({
				type : 'GET',
				url : '${systemctx}/systemmanage/preferential/deletePreferentialCode.json?id=' + id,
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					//显示AJAX请求后的提示信息
					$.fn.ajaxmessage(data);
					$('#datagrid').datagrid('reload',$('#form1').serializeObject());
				}
			});
		}
	}
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>